(function() {
	var f = function(g) {
			g = g.replace("#", "");
			return document.getElementById(g)
		},
		c, e, d = {
			extend: function(g, j, h) {
				if (h === undefined) {
					h = true
				}
				for (var i in j) {
					if (h || !(i in g)) {
						g[i] = j[i]
					}
				}
				return g
			},
			deepextend: function(g, i) {
				for (var h in i) {
					var j = i[h];
					if (g === j) {
						continue
					}
					if (typeof j === "object") {
						g[h] = arguments.callee(g[h] || {}, j)
					} else {
						g[h] = j
					}
				}
				return g
			},
			isEmpty: function(h) {
				if (h == null) {
					return true
				}
				if (this.isArray(h) || this.isString(h)) {
					return a.length === 0
				}
				for (var g in h) {
					return false
				}
				return true
			},
			isNumber: function(g) {
				return Object.prototype.toString.call(g) == "[object Number]"
			},
			isArray: function(g) {
				return Object.prototype.toString.call(g) == "[object Array]"
			},
			isString: function(g) {
				return Object.prototype.toString.call(g) == "[object String]"
			},
			isObject: function(g) {
				return Object.prototype.toString.call(g) == "[object Object]"
			},
			isFunction: function(g) {
				return typeof g === "function"
			},
			jsonp: function(h, j) {
				var i = "_CB_" + new Date().getTime();
				var g = document.createElement("script");
				g.setAttribute("type", "text/javascript");
				g.setAttribute("src", h + (/\?/.test(h) ? "&" : "?") + "callback=" + i);
				window[i] = function() {
					j.apply(this, arguments);
					document.head.removeChild(g)
				};
				document.head.appendChild(g)
			}
		};
	jsonp = d.jsonp;
	var b = function(g) {
			if ( !! c) {
				return c
			}
			e = {
				Map: AMap.Map,
				Pixel: AMap.Pixel,
				LngLat: AMap.LngLat,
				Marker: AMap.Marker,
				InfoWindow: AMap.InfoWindow,
				Size: AMap.Size,
				Icon: AMap.Icon,
				PoiSearch: AMap.PoiSearch,
				RouteSearch: AMap.RouteSearch,
				Geocoder: AMap.Geocoder,
				TileLayer: AMap.TileLayer,
				MouseTool: AMap.MouseTool,
				Polyline: AMap.Polyline,
				ContextMenu: AMap.ContextMenu
			};
			var h = {
				level: 10,
				center: new e.LngLat(116.397428, 39.90923),
				zooms: [3, 18],
				touchZoom: false,
				resizeEnable: true,
				doubleClickZoom: true,
				scrollWheel: true
			};
			if (g) {
				g.center && (g.center = new e.LngLat(g.center.lng, g.center.lat));
				h = d.extend(h, g)
			}
			b.Map.init(h);
			c = this
		};
	b._incrementor = 0;
	b.uniqueId = function(g) {
		return (g || "unique_") + ++this._incrementor
	};
	b.Event = (function() {
		var g = (function() {
			var i = 1;
			return {
				addEvent: function(j, l, k) {
					if (!k.$$$guid) {
						k.$$$guid = i++
					}
					if (!j.cusevents) {
						j.cusevents = {}
					}
					if (!j.cusevents[l]) {
						j.cusevents[l] = {}
					}
					j.cusevents[l][k.$$$guid] = k
				},
				removeEvent: function(j, l, k) {
					if (j.cusevents && j.cusevents[l]) {
						delete j.cusevents[l][k.$$$guid]
					}
				},
				fireEvent: function(l, n) {
					if (!l.cusevents) {
						return
					}
					var k = Array.prototype.slice.call(arguments, 2),
						j = l.cusevents[n];
					for (var m in j) {
						j[m].apply(l, k)
					}
				},
				clearEvent: function(k) {
					if (!k.cusevents) {
						return
					}
					for (var m in k.cusevents) {
						var j = k.cusevents[m];
						for (var l in j) {
							j[l] = null
						}
						k.cusevents[m] = null
					}
					k.cusevents = null
				},
				one: function(j, l, k) {
					var m = function() {
							k.apply(null, arguments);
							this.removeEvent(j, l, m)
						};
					this.addEvent(j, l, m)
				}
			}
		})();
		var h = {};
		return {
			bind: function(i, j) {
				g.addEvent(h, i, j)
			},
			trigger: function(i, j) {
				g.fireEvent(h, i, j)
			}
		}
	})();
	b.SERVER = "";
	b.IMGPREFIX = "ui/ui/images/";
	b.START_MARKER_ID = "marker_route_start";
	b.DEST_MARKER_ID = "marker_route_dest";
	b.PASS_MARKER_0_ID = "marker_route_passA";
	b.PASS_MARKER_1_ID = "marker_route_passB";
	b.PASS_MARKER_2_ID = "marker_route_passC";
	b.PASS_MARKER_3_ID = "marker_route_passD";
	b.WHERE_ID = "marker_where";
	b.Route = (function() {
		return {
			start: function() {}
		}
	})();
	b.Map = {
		_markers: {},
		_markerIWs: {},
		_markerData: {},
		_selectedMarker: null,
		init: function(h) {
			b.SERVER = h.server ? h.server : b.SERVER;
			b.IMGPREFIX = h.imgprefix ? h.imgprefix : b.IMGPREFIX;
			var g = new e.Map("imap", h);
			g.plugin(["AMap.ToolBar", "AMap.OverView", "AMap.Scale"], function() {
				tool = new AMap.ToolBar();
				g.addControl(tool);
				view = new AMap.OverView();
				g.addControl(view);
				scale = new AMap.Scale();
				g.addControl(scale)
			});
			/*var k;
			var j = new e.ContextMenu();
			j.className = "context_menu";
			j.addItem("从这里出发", function() {
				b.Map.addStartMarker({
					position: k,
					draggable: !0
				})
			}, 0);
			j.addItem("到这里去", function() {
				b.Map.addDestMarker({
					position: k,
					draggable: !0
				})
			}, 0);
			j.addItem("添加途经点A", function i() {
				b.Map.addPassMarker({
					position: k,
					draggable: !0
				}, 0)
			}, 0);
			j.addItem("添加途经点B", function i() {
				b.Map.addPassMarker({
					position: k,
					draggable: !0
				}, 1)
			}, 0);
			j.addItem("添加途经点C", function i() {
				b.Map.addPassMarker({
					position: k,
					draggable: !0
				}, 2)
			}, 0);
			j.addItem("添加途经点D", function i() {
				b.Map.addPassMarker({
					position: k,
					draggable: !0
				}, 3)
			}, 0, !0);
			j.addItem("这是哪儿", function() {
				b.Map.addPoiMarker({
					id: b.WHERE_ID,
					position: k
				}, null, {
					click: function(l) {
						b.Map.openMarkerTips(b.WHERE_ID, l.lnglat)
					}
				});
				b.Map.openMarkerTips(b.WHERE_ID, k, true)
			}, 0);
			j.addItem("设为地图中心点", function() {
				b.Map.setCenter(k)
			}, 0, !0);
			j.addItem("清空地图", function() {
				b.Map.clearMap()
			}, 0);
			g.bind(g, "rightclick", function(l) {
				k = l.lnglat;
				j.open(g, l.lnglat)
			});*/
			this.mapObj = g;
		},
		getMap: function() {
			return this.mapObj
		},
		getMarker: function(g) {
			return this._markers[g]
		},
		getMarkers: function() {
			return this._markers
		},
		getIWs: function(g) {
			return this._markerIWs[g]
		},
		focusMarker: function(g) {
			if (!g) {
				return this._selectedMarker
			}
			if (d.isString(g)) {
				g = this.getMarker(g)
			}
			if (d.isObject(g)) {
				if (this._selectedMarker && this._selectedMarker.id != g.id) {
					this.unfocusMarker(this._selectedMarker)
				}
				this._selectedMarker = g;
				this.getMap().trigger(g, "mouseover")
			}
		},
		unfocusMarker: function(g) {
			if (d.isString(g)) {
				g = this.getMarker(g)
			}
			if (d.isObject(g)) {
				if (this._selectedMarker && this._selectedMarker.id == g.id) {
					this._selectedMarker = null;
					this.getMap().trigger(g, "mouseout")
				}
			}
		},
		getOverlays:function(g){
			return this.getMap().getOverlays();	
		},
		addLayer: function(g) {
			this.getMap().addLayer(g)
		},
		removeLayer: function(g) {
			this.getMap().removeLayer(g)
		},
		addOverlays: function(g) {
			this.getMap().addOverlays(g)
		},
		removeOverlays: function(g) {
			this.getMap().removeOverlays(g)
		},
		clearOverlays: function() {
			this.getMap().clearOverlays()
		},
		clearInfoWindow: function() {
			this.getMap().clearInfoWindow()
		},
		clearMap: function() {
			this.closeAllMarkerIW();
			this.clearOverlays();
			this.clearInfoWindow();
			this.clearRoute();
			this.getMap().clearMap();
			b.Event.trigger("mapclear")
			b.Map._selectedMarker = null;
			b.Map._markerData = {};
			b.Map._markerIWs = {};
			b.Map._markers = {};
			b._incrementor = 0;
		},
		createPolyline: function(g, i) {
			var j = {
				id: b.uniqueId("polyline_"),
				path: g,
				strokeColor: "#FE383A",
				strokeOpacity: 0.8,
				strokeWeight: 3,
				visible: !0,
				zindex: 11
			};
			j = d.extend(j, i);
			var h = new e.Polyline(j);
			this.addOverlays(h)
		},
		createIW: function(i) {
			var h = {
				isCustom: !0,
				autoMove: !0,
				size: new e.Size(340, 0),
				offset: {
					x: -155,
					y: -40
				}
			};
			h = d.extend(h, i);
			var g = new e.InfoWindow(h);
			this._markerIWs[h.id] = g;
			return g
		},
		createPoiIW: function(h, g) {
			return this.createIW(d.extend({
				content: h
			}, g))
		},
		closeMarkerIW: function(h) {
			this.unfocusMarker(h);
			var g = this.getIWs(h);
			g && g.isOpen && g.close();
		},
		closeAllMarkerIW: function() {
			for (var g in this._markerIWs) {
				this.closeMarkerIW(g)
			}
		},
		createMarker: function(m, j) {
			var g = new e.Marker(d.extend({
				draggable: !1,
				visible: !0
			}, m));
			this._markers[g.id] = g;
			this._markerData[g.id] = m;
			for (var h in j) {
				var l = d.isString(h) ? h : 0;
				var k = d.isFunction(j[h]) ? j[h] : 0;
				l && k && this.getMap().bind(g, l, k)
			}
			return g
		},
		createPoiMarker: function(l, m, j) {
			var h = this;
			if (!d.isNumber(m)) {
				return this.createMarker(d.extend({
					icon: new e.Icon({
						image: b.IMGPREFIX + "pois.png",
						size: new e.Size(26, 30),
						imageOffset: new e.Pixel(-337, -30)
					}),
					offset: {
						x: -11,
						y: -30
					}
				}, l), j)
			}
			var k = document.createElement("div");
			var n = function(o) {
					o.style.cursor = "pointer";
					o.style.background = "url(" + b.IMGPREFIX + "pois.png) no-repeat " + (-5 + -32.2 * m) + "px -172px";
					o.style.width = "26px";
					o.style.height = "30px";
					o.style.position = "absolute";
					o.style.top = "0px";
					o.style.left = "0px";
					return o
				};
			var i = {
				content: n(k),
				offset: {
					x: -11,
					y: -30
				}
			},
				j = j || {};
			j.click1 = j.click ||
			function() {};
			j.mouseover1 = j.mouseover ||
			function() {};
			j.mouseout1 = j.mouseout ||
			function() {};
			j.click = function() {
				j.click1();
				var o = h.getIWs(g.id);
				o.open(h.getMap(), g.getPosition());
				h.focusMarker(g);
			};
			j.mouseover = function() {
				j.mouseover1();
				g.setzIndex(9999);
				k.style.background = "url(" + b.IMGPREFIX + "pois.png) no-repeat " + (-5 + -39 * m) + "px -96px";
				k.style.width = "30px";
				k.style.height = "38px";
				k.style.position = "absolute";
				k.style.top = "-7px";
				k.style.left = "-3px";
				b.Event.trigger("mouseover", g)
			};
			j.mouseout = function() {
				j.mouseout1();
				var o = h.focusMarker();
				if (!o || o.id != l.id) {
					g.setzIndex(0), n(k), (b.Event.trigger("mouseout", g))
				}
			};
			var g = this.createMarker(d.extend(i, l), j);
			return g
		},
		addPoiMarker: function(i, j, h) {
			var g = this.createPoiMarker(i, j, h);
			this.closeAllMarkerIW();
			this.addOverlays(g);
			return g
		},
		addMarker: function(i, h) {
			var h = h || {};
			h.click1 = h.click ||
			function() {};
			h.click = function() {
				h.click1()
			};
			var g = this.createMarker(i, h);
			this.closeAllMarkerIW();
			this.addOverlays(g);
			return g
		},
		_route: {},
		clearRoute: function() {
			this._route = {}
		},
		createRoute: function(g, j) {
			if (d.isString(g)) {
				var h = g.split(",");
				g = new e.LngLat(h[0], h[1])
			}
			if (j) {
				var k = {
					start: b.START_MARKER_ID,
					end: b.DEST_MARKER_ID,
					pass0: b.PASS_MARKER_0_ID,
					pass1: b.PASS_MARKER_1_ID
				};
				var i = k[j];
				this._route[i] = g;
				b.Service.describeLngLat(g, function(l) {
					var m = l;
					m.position = g;
					m.id = i;
					b.Event.trigger(j, m)
				})
			}
		},
		_createStartDestMarker: function(g, i, h) {
			var j = document.createElement("div");
			j.style.background = g ? "url(" + b.IMGPREFIX + "pois.png) no-repeat -334px -180px" : "url(" + b.IMGPREFIX + "pois.png) no-repeat -334px -134px";
			j.style.cursor = "pointer";
			j.style.width = "40px";
			j.style.height = "44px";
			j.style.position = "absolute";
			return this.createMarker(d.extend({
				content: j,
				zIndex: 31,
				offset: {
					x: -17,
					y: -44
				}
			}, i), h)
		},
		_createPassMarker: function(g, i, h) {
			var j = document.createElement("div");
			j.style.background = "url(" + b.IMGPREFIX + "pois.png) no-repeat -390px -" + (46 * g) + "px";
			j.style.cursor = "pointer";
			j.style.width = "40px";
			j.style.height = "44px";
			j.style.position = "absolute";
			return this.createMarker(d.extend({
				content: j,
				zIndex: 31,
				offset: {
					x: -17,
					y: -44
				}
			}, i), h)
		},
		createStartMarker: function(h, g) {
			return this._createStartDestMarker(!0, h, g)
		},
		createDestMarker: function(h, g) {
			return this._createStartDestMarker(!1, h, g)
		},
		createPassMarker: function(h, g) {
			return this._createPassMarker(h.list, h, g)
		},
		addStartMarker: function(j, i) {
			if (d.isString(j)) {
				this._markerIWs[b.START_MARKER_ID] = this.getIWs(j);
				j = this.getMarker(j)
			}
			var h = {
				id: b.START_MARKER_ID,
				position: j.position,
				zIndex: 10000,
				draggable: j.draggable || 0
			};
			i = i || {};
			i.click = function(k) {
				b.Map.openMarkerTips(h.id, k.lnglat)
			};
			i.dragend = function(k) {
				b.Map.createRoute(k.lnglat, "start")
			};
			var g = this.createStartMarker(h, i);
			this.closeMarkerIW(h.id);
			this.addOverlays(g);
			this.createRoute(h.position, "start");
			return g
		},
		addDestMarker: function(j, i) {
			if (d.isString(j)) {
				this._markerIWs[b.DEST_MARKER_ID] = this.getIWs(j);
				j = this.getMarker(j)
			}
			var h = {
				id: b.DEST_MARKER_ID,
				position: j.position,
				zIndex: 10000,
				draggable: j.draggable || 0
			};
			i = i || {};
			i.click = function(k) {
				b.Map.openMarkerTips(h.id, k.lnglat)
			};
			i.dragend = function(k) {
				b.Map.createRoute(k.lnglat, "end")
			};
			var g = this.createDestMarker(h, i);
			this.closeMarkerIW(h.id);
			this.addOverlays(g);
			this.createRoute(h.position, "end");
			return g
		},
		addPassMarker: function(j, k, i) {
			if (d.isString(j)) {
				this._markerIWs["PASS_MARKER_" + k + "_ID"] = this.getIWs(j);
				j = this.getMarker(j)
			}
			var h = {
				id: b["PASS_MARKER_" + k + "_ID"],
				list: k,
				position: j.position,
				zIndex: 10000,
				draggable: j.draggable || 0
			};
			i = i || {};
			i.click = function(l) {
				b.Map.openMarkerTips(h.id, l.lnglat)
			};
			i.dragend = function(l) {
				b.Map.createRoute(l.lnglat, "pass" + k)
			};
			var g = this.createPassMarker(h, i);
			this.closeMarkerIW(h.id);
			this.addOverlays(g);
			this.createRoute(h.position, "pass" + k);
			return g
		},
		openMarkerTips: function(j, h, g) {
			var i = b.Map.getIWs(j);
			if (!i || g) {
				b.Service.describeLngLat(h, function(k) {
					var m = {
						id: j,
						x: h.lng,
						y: h.lat
					};
					if (k.status == "E0") {
						var l = k;
						l.position = h;
						l.id = j;
						if (k.list) {
							m.province = k.list[0].province.name;
							m.city = k.list[0].city.name;
							m.district = k.list[0].district.name;
							if (k.list[0].poilist) {
								m.address = k.list[0].poilist[0].address
							}
							if (k.list[0].roadlist) {
								m.road = k.list[0].roadlist[0].name
							}
							m.name = (m.city ? (m.province + m.city) : m.province) + m.district
						} else {
							m.name = "未知位置";
							m.road = "未知道路"
						}
					} else {
						m.name = "未知位置";
						m.road = "未知道路"
					}
					b.Map.createPoiIW(b.View.getHTML("SimpleInfoWindow", m), {
						id: j
					}).open(b.Map.getMap(), h);
					if (j == b.WHERE_ID) {
						b.Event.trigger("where", l)
					}
				})
			} else {
				i.open(b.Map.getMap(), h)
			}
		},
		setZoom: function(g) {
			this.getMap().setZoom(g)
		},
		setCenter: function(g) {
			this.getMap().setCenter(g)
		},
		setCity: function(g, h) {
			this.getMap().setCity(g, h)
		},
		setFitView: function(h, g) {
			if (h && h.length == 1) {
				this.setCenter(h[0].position);
				this.setZoom(13);
				return
			}
			this.getMap().setFitView(h, g)
		},
		setMouseTool: function(i, h) {
			h = h || {};
			if (-1 < "marker,polyline,circle,rule,rectZoomIn,rectZoomOut,polygon,rectangle,measureArea,panWheelZoom,close,_unbind".indexOf(i)) {
				var g = this.getMap()
			}
			if (g.jd) {
				g.jd[i](h)
			} else {
				g.plugin("AMap.MouseTool", function() {
					g.jd = new AMap.MouseTool(g);
					g.jd[i](h);
					g.bind(g.jd, "draw", function(j) {
						g.bind(j, "click", function(k) {
							b.Map.openMarkerTips(j.id, k.lnglat)
						});
						g.jd._unbind()
					})
				})
			}
		},
		_trafficStatus: false,
		switchTraffic: function() {
			if (!this._trafficStatus) {
				var g = new e.TileLayer({
					tileSize: 256,
					zIndex: 5,
					id: "trafficLay",
					getTileUrl: function(h, j, i) {
						return "http://tm.mapabc.com/trafficengine/mapabc/traffictile?v=1.0&t=1&zoom=" + (17 - i) + "&x=" + h + "&y=" + j
					}
				});
				this.addLayer(g)
			} else {
				this.removeLayer("trafficLay")
			}
			this._trafficStatus = !this._trafficStatus
		},
		poimouseclick: function(h) {
			var g = this.getMarker(h);
			this.getMap().trigger(g, "click")
		},
		poimouseover: function(h) {
			var g = this.getMarker(h);
			this.getMap().trigger(g, "mouseover")
		},
		poimouseout: function(h) {
			var g = this.getMarker(h);
			var i = this.focusMarker();
			(!i || i.id != g.id) && (this.getMap().trigger(g, "mouseout"))
		},
		drawrouteline: function(g) {
			var h = this._route.lines[g];
			this.createPolyline(h, {
				id: "routelinehighlight",
				strokeColor: "#ff0000",
				strokeWeight: 5
			})
		},
		drawroutelineclick: function(g) {
			var h = this._route.lines[g];
			this.setCenter(h[parseInt(h.length / 2)])
		},
		savePOIPoint : function(o){ //保存POI点
			var top = parent || window;
			var _data = this._markerData[o];
			var data = "{'telephone':'"+_data.tel+"','longitude':'"+_data.x+"','latitude':'"+_data.y+"','address':'"+_data.address+"','name':'"+_data.name+"'}";
			top.ajax && top.ajax('savePoiPointPost',data,'POST',function(ret){
				if( ret.code == 1 ){alert('保存成功.');}	
			});
		},
		sendPOIPoint : function(o,fn){ //发送POI点到车
			var top = parent || window;
			var _data = this._markerData[o];
			var data = "{'telephone':'"+_data.tel+"','longitude':'"+_data.x+"','latitude':'"+_data.y+"','address':'"+_data.address+"','name':'"+_data.name+"'}";
			top.ajax && top.ajax('saveSendPoiPoint',data,'POST',function(ret){
				if( ret.code == 1 ){alert('保存成功.');}	
			});
		}
	};
	b.Service = {
		describeLngLat: function(g, k) {
			if (d.isString(g)) {
				var h = g.split(",");
				g = new e.LngLat(h[0], h[1])
			} else {
				if (d.isObject(g) && !(g instanceof e.LngLat)) {
					g = new e.LngLat(g.lng, g.lat)
				}
			}
			var i = {
				range: 1000,
				crossnum: 2,
				roadnum: 3,
				poinum: 2
			};
			var j = new e.Geocoder(i);
			j.regeocode(g, function(l) {
				k.call(this, l)
			})
		},
		getNaviPath: function(o, m, q) {
			var r = {};
			r = d.extend(r, q);
			if (!b.SERVER) {
				var j = new e.RouteSearch(r);
				j.getNaviPath(o, function(i) {
					m.call(this, i)
				})
			} else {
				var p = o.concat();
				var n = p.shift();
				var k = p.pop();
				var g = b.SERVER + "tservice/gisnavi/routing/getRoutingCalculation?_type=json&fromX=" + n.lng + "&fromY=" + n.lat + "&toX=" + k.lng + "&toY=" + k.lat;
				g += r.routeType != null ? "&policy=" + r.routeType : "";
				var l = [];
				for (var h = 0; h < p.length; h++) {
					l.push(p[h].lng + "," + p[h].lat)
				}
				g += l.length ? "&viapoints=" + l.join("|") : "";
				d.jsonp(g, function(i) {
					m.call(this, i)
				})
			}
		},
		poiDeep: function(i, h) {
			if (b.SERVER) {
				return
			}
			var g = b.SERVER + "tservice/gisnavi/poideep/getPoiDeepInformation/" + i;
			d.jsonp(g, function(j) {
				h.call(this, j)
			})
		},
		cenPoi: function(g, h, k) {
			var i = {
				srctype: "POI",
				number: 10,
				batch: 1,
				range: 3000,
				ext: ""
			};
			var j = new e.PoiSearch(i);
			j.byCenPoi(g, h, function(l){
				k.call(this, l)
			})
		},
		addressMatch: function(g, j) {
			var h = {
				range: 1000,
				crossnum: 2,
				roadnum: 3,
				poinum: 2
			};
			var i = new e.Geocoder(h);
			i.geocode(g, function(k) {
				if (k.status == "E0") {
					d.isFunction(j) && j.call(this, k)
				} else {
					j.call(this, {})
				}
			})
		},
		roadCrossSearchByRoadName: function(i, j, k) {
			var h = {
				number: 10,
				batch: 1,
				ext: ""
			};
			var g = new AMap.RoadSearch(h);
			g.roadCrossSearchByRoadName(i, j, function(l) {
				if (l.status == "E0") {
					k.call(this, l)
				} else {
					k.call(this, {})
				}
			})
		},
		inputPrompt: function(g, i, k) {
			var h = {
				srctype: "POI",
				type: "",
				number: 10,
				batch: 1,
				range: 3000,
				ext: ""
			};
			var j = new e.PoiSearch(h);
			j.inputPrompt(g, i, function(l) {
				d.isFunction(k) && k.call(this, l)
			})
		}
	};
	b.View = {
		_templates: {
			//PoiInfoWindow: '<div class="info"><div class="info-top"><div>{{name}}</div><img src="http://api.amap.com/webapi/static/Images/close2.gif" onclick="CMap.Map.closeMarkerIW(\'{{id}}\')"></div><div class="info-middle"><div>名称：{{name}}<br/>经度：{{x}}，纬度：{{y}}<br/>地址：{{address}}<br/>电话：{{tel}}<br/>类型：{{type}}</div><div><button onclick="CMap.Map.addStartMarker(\'{{id}}\')">设为起点</button><button onclick="CMap.Map.addDestMarker(\'{{id}}\')">设为终点</button><button onclick="CMap.Map.addPassMarker(\'{{id}}\',0)">设为途经点A</button><button onclick="CMap.Map.addPassMarker(\'{{id}}\',1)">设为途经点B</button><button onclick="CMap.Map.savePOIPoint()">保存当前位置</button></div></div><div class="info-bottom"><img src="http://api.amap.com/webapi/static/Images/sharp.png"></div></div>',
			PoiInfoWindow:'<div class="info"><div class="info-top"><div>{{name}}</div><img src="http://api.amap.com/webapi/static/Images/close2.gif" onclick="CMap.Map.closeMarkerIW(\'{{id}}\')"></div><div class="info-middle"><div>名称：{{name}}<br/>经度：{{x}}，纬度：{{y}}<br/>地址：{{address}}<br/>电话：{{tel}}</div><div><button onclick="CMap.Map.savePOIPoint(\'{{id}}\')">保存当前位置</button><button onclick="CMap.Map.sendPOIPoint(\'{{id}}\')">发送到车机</button></div></div><div class="info-bottom"><img src="http://api.amap.com/webapi/static/Images/sharp.png"></div></div>',
			SimpleInfoWindow: '<div class="info"><div class="info-top"><div>{{name}}</div><img src="http://api.amap.com/webapi/static/Images/close2.gif" onclick="CMap.Map.closeMarkerIW(\'{{id}}\')"></div><div class="info-middle"><div>{{name}}，临近{{road}}<br/>经度：{{x}}，纬度：{{y}}<br/></div><div><button onclick="CMap.Map.addStartMarker(\'{{id}}\')">设为起点</button><button onclick="CMap.Map.addDestMarker(\'{{id}}\')">设为终点</button><button onclick="CMap.Map.addPassMarker(\'{{id}}\',0)">设为途经点A</button><button onclick="CMap.Map.addPassMarker(\'{{id}}\',1)">设为途经点B</button></div></div><div class="info-bottom"><img src="http://api.amap.com/webapi/static/Images/sharp.png"></div></div>'
		},
		getTemplate: function(g) {
			return this._templates[g]
		},
		getHTML: function(h, i) {
			h = h || "PoiInfoWindow";
			var g = this.getTemplate(h);
			return g.replace(/\{{2}(\w+)?\}{2}/g, function(k, j) {
				return k.replace(k, i[j] || "暂无")
			})
		}
	};
	b.prototype.setZoom = function(g){
		b.Map.setZoom(g);	
	}
	
	b.prototype.showMarker = function(g){
		g = b.Map.getMarker(g);
		b.Map.closeAllMarkerIW();
		b.Map.getMap().trigger(g,'click');
	};
	b.prototype.clearMap = function() {
		b.Map.clearMap()
	};
	b.prototype.removeMarkersByType = function(h) {
		if (!h) {
			return
		}
		var g = b.Map.getMarkers();
		for (var i in g) {
			if (i.indexOf(h) > -1) {
				b.Map.removeOverlays(i)
			}
		}
	};
	b.prototype.setFitView = function() {
		b.Map.setFitView()
	};
	b.prototype.setCenter = function(g) {
		if (d.isString(g)) {
			var h = g.split(",");
			g = new e.LngLat(h[0], h[1])
		} else {
			if (d.isObject(g) && !(g instanceof e.LngLat)) {
				g = new e.LngLat(g.lng, g.lat)
			}
		}
		b.Map.setCenter(g)
	};
	b.prototype.setCity = function(g, h) {
		b.Map.setCity(g, h)
	};
	b.prototype.poiSearch = function(h, g, k, m, i) {
		b.Map.clearMap();
		var j = {
			srctype: "POI",
			number: 10,
			batch: 1,
			range: 3000,
			ext: ""
		};
		j = d.extend(j, i);
		var l = new e.PoiSearch(j);
		l.byCenKeywords(h, g, k, function(r) {
			if (r.status == "E0") {
				var p = [];
				for (var q = 0; q < r.list.length; q++) {
					var n = b.uniqueId("marker_poi_");
					var s = r.list[q];
					s.position = new e.LngLat(s.x, s.y);
					s.id = n;
					p.push(b.Map.addPoiMarker(s, q));
					b.Map.createPoiIW(b.View.getHTML(null, s), {
						id : n
					})
				}
				b.Map.setFitView(p)
			}
			!!m && m.call(this, r)
		})
	};
	b.prototype.diyPoint = function(r){
		b.Map.clearMap();
		var p = new Array();
		for( var q = 0 ;q < r.length ;q++ ){
			var n = b.uniqueId("marker_poi_");
			var s = r[q];
			s.position = new e.LngLat(s.longitude, s.latitude);
			s.id = n;
			s.x = s.longitude;
			s.y = s.latitude;
			s.tel = s.telephone;
			p.push(b.Map.addPoiMarker(s, q));
			b.Map.createPoiIW(b.View.getHTML(null, s), {
				id : n
			});
			b.Map.setFitView(p)
		}
	}
	b.prototype.poiDeep = function(h, g) {
		b.Service.poiDeep(h, function() {
			g.call(this, data)
		})
	};
	b.prototype.routeSearch = function(i, h, j) {
		var g = b.Map._route.lines = [];
		b.Service.getNaviPath(i, function(p) {
			if (p.status == "E0") {
				var q = [];
				for (var o = 0; o < p.list.length; o++) {
					var r = p.list[o].coor.split(";");
					var k = [];
					for (var n = 0; n < r.length; n++) {
						var m = r[n].split(",");
						var l = new e.LngLat(m[0], m[1]);
						k.push(l);
						q.push(l)
					}
					g.push(k)
				}
				b.Map.createPolyline(q, {
					id: "navi",
					strokeColor: "#8c87f7",
					strokeWeight: 5
				})
			}
			b.Event.trigger("routecreate", p);
			j.call(this, p)
		}, h)
	};
	b.prototype.cenPoi = function(g, h, i) {
		b.Service.cenPoi(g, i)
	};
	b.prototype.getGeocodeSearch = function(g, j) {
		var h = {
			range: 1000,
			crossnum: 2,
			roadnum: 3,
			poinum: 2
		};
		var i = new e.Geocoder(h);
		i.geocode(g, function(k) {
			j.call(this, k)
		})
	};
	b.prototype.getRegeocodeSearch = function(g, h) {
		b.Service.describeLngLat(g, h)
	};
	b.prototype.getRoadCrossSearchByRoadName = function(g, h, i) {
		b.Service.roadCrossSearchByRoadName(g, h, i)
	};
	b.prototype.autoComplete = function(g, h, i) {
		if (g != "") {
			b.Service.inputPrompt(g, h, function(j) {
				i.call(this, j)
			})
		} else {
			i.call(this, false)
		}
	};
	b.prototype.showGPSPosition = function(h, j, n) {
		if (d.isString(h)) {
			h = [h]
		}
		var w = function(A, i, z) {
				A.style.cursor = "pointer";
				A.style.background = "url(" + b.IMGPREFIX + "pois.png) no-repeat " + (-5 + -32.2 * i) + "px -" + z + "px";
				A.style.width = "26px";
				A.style.height = "30px";
				A.style.position = "absolute";
				A.style.top = "0px";
				A.style.left = "0px";
				return A
			};
		var l = (j == "ecall" || j == "bcall") ? 210 : 0;
		var u = [];
		var t = [];
		for (var v = 0; v < h.length; v++) {
			var r = document.createElement("div");
			var x = b.uniqueId("marker_xcall");
			var k = new e.LngLat(h[v].lng, h[v].lat);
			var g = {
				id: x,
				content: w(r, v, l),
				position: k,
				offset: {
					x: -11,
					y: -30
				}
			};
			(function(i, A, z) {
				t.push(b.Map.addMarker(z, {
					click: function() {
						b.Map.openMarkerTips(i, A)
					}
				}))
			})(x, k, g);
			u.push(k)
		}
		if (j == "ecall" || j == "bcall") {
			b.Map.createPolyline(u);
			var r = document.createElement("div");
			r.style.cursor = "pointer";
			r.style.background = "url(" + b.IMGPREFIX + "direct.png) no-repeat";
			r.style.width = "60px";
			r.style.height = "60px";
			r.style.position = "absolute";
			r.style.top = "0px";
			r.style.left = "0px";
			r.style.WebkitTransform = "rotate(" + n.direction + "deg)";
			r.style.MozTransform = "rotate(" + n.direction + "deg)";
			r.style.OTransform = "rotate(" + n.direction + "deg)";
			r.style.msTransform = "rotate(" + n.direction + "deg)";
			var s = height = 60,
				y = parseInt(n.direction) * Math.PI * 2 / 360,
				m = Math.sin(y),
				o = Math.cos(y),
				q = -s / 2 * o + height / 2 * m + s / 2,
				p = -s / 2 * m - height / 2 * o + height / 2;
			r.style.filter = "progid:DXImageTransform.Microsoft.Matrix(M11=" + o + ", M12=-" + m + ",M21=" + m + ", M22=" + o + ", Dx=" + q + ", Dy=" + p + '")';
			var g = {
				id: "marker_xcall_arrow",
				content: r,
				zIndex: 1,
				position: k,
				offset: {
					x: -29,
					y: -33
				}
			};
			b.Map.addMarker(g)
		}
		b.Map.setFitView(t)
	};
	window.CMap = b
})();